package com.gsn.poker.play;

import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.gsn.engine.myplay.GsnGame;
import com.gsn.poker.asset.PokerTexture;

public class ChipGroup extends Group {
	ChipGroupLogic logic = new ChipGroupLogic();
	float coinWid;
	float coinHei;
	float arrX[] = new float[5];
	float arrY[] = new float[5];
	public ChipGroup() {
		transform = GsnGame.transform;
		coinWid = PokerTexture.inst().chip.get(0).getRegionWidth();
		coinHei = PokerTexture.inst().chip.get(0).getRegionHeight();
		this.width = coinWid * 3;
		//this.height = coinHei * 4;
		arrX[0] = 0; arrY[0] = coinHei;
		arrX[1] = coinWid; arrY[1] = coinHei;
		arrX[2] = coinWid * 2; arrY[2] = coinHei;
		arrX[3] = coinWid * 0.5f; arrY[3] = 0;
		arrX[4] = coinWid * 1.5f; arrY[4] = 0;
	}
	
	public void setMoney(long money){
		clear();
		logic.convertMoneyToChip(money);
		for (int i = 0; i < logic.finalChipList.size(); i++){
			addImg(i, logic.finalChipValueList.get(i), logic.finalChipList.get(i));			
		}
	}
		

	private void addImg(int stt, Long value, Long num) {		
		//for (int i = 0)
		int type = ChipGroupLogic.getType(value);
		float tmpX = arrX[stt];
		float tmpY = arrY[stt];
		for (int i = 0; i < num; i++){
			Image img = new Image(PokerTexture.inst().chip.get(type % 5));
			img.x = tmpX;
			img.y = tmpY + coinHei * 0.2f * i;
			addActor(img);
		}
	}
}
